package cn.shutdown.demo.jvm;

import java.util.ArrayList;
import java.util.List;

/**
 *  测试堆内在OOM指定dump文件及触发脚本
 * -XX:+PrintGCDetails -Xmx20m -Xms5m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=DumpOOM.dump "-XX:OnOutOfMemoryError=/Users/jiangwujie/IdeaProjects/demo/printStack.sh %p"
 * @author jiangwujie
 * @date 2021/6/16
 */
public class DumpOOM {

    public static void main(String[] args) {
        List l = new ArrayList<>();
        for (int i = 0; i < 100; i++) {
            l.add(new byte[1 * 1024 * 1024]);
            System.out.println("分配了1M内存");
        }
    }
}
